#pragma once

//为了高效利用内存不频繁创建和删除
//创建此栈兼列表
//具有栈有的功能和遍历功能
template<typename T, int s>
class Stack_list
{
public:
	void push(T t) {
		this->pointer++;
		this->arr[this->pointer] = t;
	};
	T pop() {
		//如果空了直接返回NULL
		if (this->pointer < 0) throw "不能访问-1";
		this->pointer--;
		return this->arr[this->pointer + 1];
	};
	bool empty() {
		return this->pointer == -1;
	};          //空的才返回true
	int size()
	{
		return this->pointer + 1;
	}
	T geti(int i)
	{

		return this->arr[i];
	}
	//重置
	void setNull()
	{
		this->pointer = -1;
	}


private:
	T arr[s];                //存储对象的核心数组
	int pointer = -1;           //这个元素的值是最上面的元素的下标

};

